import { Context } from 'koa'
// 请求成功编码处理
export const sucessCode = (
  ctx: Context,
  code: number = 200,
  msg: string,
  data: any = ''
) => {
  ctx.body = {
    code,
    msg,
    data,
  }
}

export const warnCode = (ctx: Context, code: number = 300, msg: string) => {
  ctx.body = {
    code,
    msg,
  }
}

// 请求失败编码处理
export const errCode = (
  ctx: Context,
  code: number = 500,
  msg: string,
  err: Error
) => {
  ctx.body = {
    code,
    msg,
    err,
  }
}
